package com.dragon.modules.yuegou.enums.order;

import com.fasterxml.jackson.annotation.JsonCreator;

import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 配送状态
 *
 * @author pbuilder generated
 *
 */
public enum OrderShippingStatus {

	/**
	 * 未发货
	 */
	NO_DELIVER(0, "未发货"),
	/**
	 * 已发货未接单
	 */
	DELIVER(1, "已发货未接单"),
	/**
	 * 已接单
	 */
	ORDER(2, "已接单"),
	/**
	 * 已取货
	 */
	PICK_UP(3, "已取货"),
	/**
	 * 已送达
	 */
	DELIVERY(4, "已送达"),
	/**
	 * 已收货
	 */
	GOODS(5, "已收货"),
	/**
	 * 骑手拒单
	 */
	REFUSE(6, "骑手拒单"),
	/**
	 * 取消订单
	 */
	CANCEL(7, "取消订单");

	/**
	 * 枚举标识
	 */
	private final Integer code;

	/**
	 * 别名
	 */
	private final String alias;

	private OrderShippingStatus(Integer code, String alias) {
		this.code = code;
		this.alias = alias;
	}

	public Integer getValue() {
		return code;
	}

	/**
	 * 枚举标识
	 *
	 * @return code
	 */
	public Integer getCode() {
		return code;
	}

	/**
	 * 别名
	 *
	 * @return alias
	 */
	public String getAlias() {
		return alias;
	}

	/**
	 * 把code转化为费用类型枚举
	 *
	 * @param code 代码
	 * @return
	 */
	@JsonCreator
	public static OrderShippingStatus from(Integer code) {
		if (code == null) {
			return null;
		}
		return CODE_MAP.get(code);
	}

	/**
	 * Code Map for OrderShippingStatus
	 */
	private static final Map<Integer, OrderShippingStatus> CODE_MAP = Stream.of(OrderShippingStatus.values())
			.collect(Collectors.toMap(OrderShippingStatus::getCode, e -> e));

}
